package cn.sinata.wanglin.adapter;


import android.text.TextUtils;

import com.facebook.drawee.view.SimpleDraweeView;
import com.xilada.xldutils.adapter.HFRecyclerAdapter;
import com.xilada.xldutils.adapter.util.ViewHolder;
import java.util.List;
import cn.sinata.wanglin.R;
import cn.sinata.wanglin.model.Newsinfo;
import cn.sinata.wanglin.utils.RelativeDateFormat;

public class NewsinfoAdapter extends HFRecyclerAdapter<Newsinfo> {
    public NewsinfoAdapter(List<Newsinfo> mData) {
        super(mData, R.layout.item_newsinfo);
    }

    @Override
    public void onBind(int position, Newsinfo data, ViewHolder holder) {
        ((SimpleDraweeView) holder.bind(R.id.iv_headview)).setImageURI(data.getNewsImg());
        if(!TextUtils.isEmpty(data.getCreateDate())){
            holder.setText(R.id.tv_time, RelativeDateFormat.format(data.getCreateDate()));
        }else{
            holder.setText(R.id.tv_time,"");
        }
        if(!TextUtils.isEmpty(data.getNewsTitle())){
            holder.setText(R.id.tv_title,data.getNewsTitle());
        }else{
            holder.setText(R.id.tv_title,"暂无新闻标题");
        }
        if(!TextUtils.isEmpty(data.getNewsOut())){
            holder.setText(R.id.tv_from,data.getNewsOut());
        }else{
            holder.setText(R.id.tv_from,"暂无来源信息");
        }
        if(!TextUtils.isEmpty(data.getCommentCount())){
            holder.setText(R.id.tv_commentnum,data.getCommentCount());
        }else{
            holder.setText(R.id.tv_commentnum,"0");
        }
    }
}
